﻿@page "/RuleDetail/{RuleID}"
@using WorkFlow.Data
@using WorkFlow.Data.Model
@inject IJSRuntime JSRunTime
@inject CommentTool commentTool
@inject DataManager dataManager
<h1>RuleDetail</h1>
<div>
    <button @onclick="@(()=>Edit())" class="btn btn-primary btn-xs">Edit</button>
    <button @onclick="@(()=>Delete())" class="btn btn-primary btn-xs">Delete</button>
</div>
<br>
<div>
    Condition&nbsp;<button @onclick="@(()=>AddOpration("&"))" class="btn btn-primary btn-xs">&</button>
    <button @onclick="@(()=>AddOpration("|"))" class="btn btn-primary btn-xs">|</button>
    <button @onclick="@(()=>AddOpration("!"))" class="btn btn-primary btn-xs">!</button>
    <button @onclick="@(()=>AddOpration("="))" class="btn btn-primary btn-xs">=</button>
    <button @onclick="@(()=>AddOpration("!="))" class="btn btn-primary btn-xs">!=</button>
    <button @onclick="@(()=>AddOpration(">"))" class="btn btn-primary btn-xs">></button>
    <button @onclick="@(()=>AddOpration(">="))" class="btn btn-primary btn-xs">>=</button>
    <button @onclick="@(()=>AddOpration("<"))" class="btn btn-primary btn-xs">&lt;</button>
    <button @onclick="@(()=>AddOpration("<="))" class="btn btn-primary btn-xs">&lt;=</button>
</div>
<br>
<div id="tree" style="width:50%;">
    <Tree Items="@Items" />
</div>

<div class="modal fade" id="EditRuleDetail" tabindex="-1" role="dialog" aria-labelledby="ParamertersLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="title">Edit Rule</h4>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="model-body">
                <br>
                &ensp;&nbsp;ValueType &nbsp;
                @if (@_EditRuleDetailEntity.Type <= 3)
                {
                    <select id="ValueType" disabled="disabled" @bind="@_EditRuleDetailEntity.ValueType">
                        <option value="1">String</option>
                        <option value="2">Int</option>
                        <option value="3">Float</option>
                        <option value="4">Double</option>
                        <option value="5">Decimal</option>
                        <option value="6">Decimal</option>
                        <option value="7">DataTime </option>
                    </select>
                }
                else
                {
                    <select id="ValueType" @bind="@_EditRuleDetailEntity.ValueType">
                        <option value="1">String</option>
                        <option value="2">Int</option>
                        <option value="3">Float</option>
                        <option value="4">Double</option>
                        <option value="5">Decimal</option>
                        <option value="6">Decimal</option>
                        <option value="7">DataTime</option>
                        <option value="8">Boolean</option>
                    </select>
                }
                <br>
                <br>
                <div>
                    <div style="width:54%;float: left;">
                        &ensp;&nbsp;ParameterName&nbsp;
                        <br>
                        &ensp;
                        @if (@_EditRuleDetailEntity.Type <= 3)
                        {
                            <input type="text" disabled="disabled" @bind="@_EditRuleDetailEntity.Name"></input>
                        }
                        else
                        {
                            <input type="text" @bind="@_EditRuleDetailEntity.Name"></input>
                        }
                        <div style="width:50px; float: right;">
                            <select id="ValueType" @bind="@_EditRuleDetailEntity.Type">
                                <option value="1">&</option>
                                <option value="2">|</option>
                                <option value="3">!</option>
                                <option value="4">=</option>
                                <option value="5">!=</option>
                                <option value="6">></option>
                                <option value="7">>=</option>
                                <option value="8">&lt;</option>
                                <option value="9">&lt;=</option>
                            </select>
                        </div>
                    </div>
                    <div style="width:42%;float: left;">
                        &ensp;&nbsp;ParameterValue&nbsp;
                        <br>
                        &ensp;
                        @if (@_EditRuleDetailEntity.Type <= 3)
                        {
                            <input type="text" disabled="disabled" @bind="@_EditRuleDetailEntity.Value"></input>
                        }
                        else
                        {
                            <input type="text" @bind="@_EditRuleDetailEntity.Value"></input>
                        }
                    </div>
                </div>
                <br>
                <br>
                &nbsp;
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">close</button>
                <button type="button" class="btn btn-primary" @onclick="Save">Save</button>
            </div>
        </div>

    </div>
</div>
